package com.wujian.love.study.thread;

/**
 * @ClassName: ThreaDemo
 * @Description:
 * @Author: wuj
 * @Date: 2021-03-02 11:01
 **/
public class ThreaDemo {

    private static boolean ready;

    private static int number;

    private static class ReaderThread extends Thread{
        public  void run(){
            while (ready){
                //使当前线程由执行状态，变成为就绪状态，让出cpu时间，在下一个线程执行时候，此线程有可能被执行，也有可能没有被执行
                Thread.yield();
                System.out.println(number);
            }
        }
    }

    public static void main(String[] args) {
        new ReaderThread().start();
        number = 42;
        ready = true;
    }
}
